package com.rlz.net.demo

import org.paradisehell.convex.converter.ConvexConverterFactory
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
 * Created by RLZ
 * on 2021/9/16
 *
 */
class Retrofit {


    companion object {
        @JvmStatic
        val retrofit: Retrofit by lazy {
            Retrofit.Builder()
                .baseUrl("")
                .addConverterFactory(ConvexConverterFactory())
                .addConverterFactory(GsonConverterFactory.create())
                .build()
        }


        val testService: TestService by lazy {
            retrofit.create(TestService::class.java)
        }

    }


    /**
     * GlobalScope是生命周期是process级别的，即使Activity或Fragment已经被销毁，协程仍然在执行。所以需要绑定生命周期。
     * lifecycleScope只能在Activity、Fragment中使用，会绑定Activity和Fragment的生命周期
     * viewModelScope只能在ViewModel中使用，绑定ViewModel的生命周期
     */
}